package hn.sigit.dao.hnd.administrative;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.jboss.seam.Component;

import hn.sigit.model.hnd.administrative.HND_MunicipalTransactionType;
import hn.sigit.model.hnd.administrative.HND_TransactionMetaData;
import hn.sigit.dao.SigitDAO;

public class HND_TransactionMetaDataDAO extends SigitDAO<HND_TransactionMetaData> {
	private static final long serialVersionUID = 1L;
	
	public static List<HND_TransactionMetaData> loadRequestMetaData() {
		Session commonsDatabase = (Session)Component.getInstance(COMMONS_DB);
		return loadRequestMetaData(commonsDatabase);
	}
	public static HND_TransactionMetaData loadRequestMetaDataByRequestType(HND_MunicipalTransactionType type) {
		Session commonsDatabase = (Session)Component.getInstance(COMMONS_DB);
		return loadRequestMetaDataByRequestType(commonsDatabase, type);
	}
	
	@SuppressWarnings("unchecked")
	public static List<HND_TransactionMetaData> loadRequestMetaData(Session session) {
		Criteria criteria = session.createCriteria(HND_TransactionMetaData.class);
		
		return (List<HND_TransactionMetaData>)criteria.list();
	}
	public static HND_TransactionMetaData loadRequestMetaDataByRequestType(Session session, HND_MunicipalTransactionType type) {
		Criteria criteria = session.createCriteria(HND_TransactionMetaData.class);
		criteria.add(Restrictions.eq("municipalTrxType", type));
		
		return (HND_TransactionMetaData) criteria.uniqueResult();
	}
}
